﻿using System;
using System.Data;
using System.Data.SqlClient;

public  class AdminRegDAL
    {
      dbConnection db = new dbConnection();
      public  int CreateAccount(AdminRegBO AdminRegister)
      {
          SqlConnection cn = null;
          SqlCommand cmd = null;
          int Counter = 0;



          try
          {
              cn = new SqlConnection();
              cn.ConnectionString = db.GetCS();

              cmd = new SqlCommand();
              cmd.Connection = cn;
              cmd.CommandType = CommandType.Text;
              cmd.CommandText = "INSERT INTO [Admin] ( UserName,Password,Name,Role) VALUES (  @UserName, @Password,@Name,@Role)";
              //CONVERT(VARCHAR(20),@AccCreatedDate, 101)
              //cmd.Parameters.AddWithValue("@CategoryId", CategoryId);
              //cmd.Parameters.AddWithValue("@AccountId", Account.AccountId);


              cmd.Parameters.AddWithValue("@UserName", AdminRegister.UserName);
              cmd.Parameters.AddWithValue("@Password", AdminRegister.Password);
              cmd.Parameters.AddWithValue("@Name", AdminRegister.Name);
              cmd.Parameters.AddWithValue("@Role", AdminRegister.Role);
             
              //cmd.Parameters.AddWithValue("@CreatedDate", Register.CreatedDate);


              cn.Open();
              Counter = cmd.ExecuteNonQuery();

          }
          catch (Exception ex)
          {
              throw new Exception(ex.Message);
          }
          finally
          {
              if (cn != null)
              {
                  cn.Close();
                  cn.Dispose();
                  cn = null;
              }
          }
          return (Counter);
      }

    }

